<?php

// [ 项目验证器 ]

namespace app\common\validate;
use think\Validate;

class Project extends Validate
{
    // 验证规则
    protected $rule = [
        'member_id'    => 'require|integer|max:11',
        'title'        => 'require|length:2,40',
        'words'        => 'require|length:2,100',
        'logo'         => 'require|max:256',
        'stage'        => 'require|max:40',
        'round'        => 'require|max:20',
        'industry'     => 'require|max:400',
        'city'         => 'require|max:40',
        'money'        => 'require|integer|max:6',
        'introduction' => 'require|max:800',
        'atlas'        => 'max:6000',

        'company' => 'max:60',
        'team'    => 'max:40',
        'members' => 'max:6000',
        'bp'      => 'max:256',
    ];

    // 错误提示
    protected $message = [
        'member_id.require'    => '会员主键必须',
        'member_id.integer'    => '会员主键必须为数字',
        'member_id.max'        => '会员主键最大长度[11]',
        
        'title.require'        => '项目名称必须',
        'title.length'         => '项目名称长度[2~40]',
        
        'words.require'        => '一句话介绍必须',
        'words.length'         => '一句话介绍长度[2~100]',
        
        'logo.require'         => '项目图标必须',
        'logo.max'             => '项目图标URI最大长度[256]',
        
        'stage.require'        => '阶段必须',
        'stage.max'            => '阶段最大长度[40]',
        
        'round.require'        => '轮次必须',
        'round.max'            => '轮次最大长度[20]',
        
        'industry.require'     => '轮次必须',
        'industry.max'         => '轮次最大长度[200]',
        
        'city.require'         => '城市必须',
        'city.max'             => '城市最大长度[40]',
        
        'member_id.require'    => '融资金额必须',
        'member_id.integer'    => '融资金额必须为数字',
        'member_id.max'        => '融资金额最大长度[6]',
        
        'introduction.require' => '项目简介必须',
        'introduction.max'     => '项目简介最大长度[800]',
        
        'atlas.max'            => '项目图集最大长度[6000]',

        'company.max' => '公司全称最大长度[60]',
        'team.max'    => '团队规模最大长度[40]',
        'members.max' => '核心团队成员最大长度[6000]',
        'bp.max'      => '商业计划书URI最大长度[256]',
    ];
    
    // 验证场景
    protected $scene = [
        // 创建项目
        'create' => ['member_id','title','words','logo','stage','round','industry','city','money','introduction','atlas'],
        // 编辑项目
        'edit'   => ['title','words','logo','stage','round','industry','city','money','introduction','atlas'],
        // 完善项目信息
        'complete' => ['company','team','members','bp'],
    ];
}